import 'package:flutter_fronter_service/generated/json/base/json_convert_content.dart';
import 'package:flutter_fronter_service/model/goods_item_entity.dart';

GoodsItemEntity $GoodsItemEntityFromJson(Map<String, dynamic> json) {
  final GoodsItemEntity goodsItemEntity = GoodsItemEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    goodsItemEntity.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    goodsItemEntity.name = name;
  }
  final double? price = jsonConvert.convert<double>(json['price']);
  if (price != null) {
    goodsItemEntity.price = price;
  }
  final String? picture = jsonConvert.convert<String>(json['picture']);
  if (picture != null) {
    goodsItemEntity.picture = picture;
  }
  return goodsItemEntity;
}

Map<String, dynamic> $GoodsItemEntityToJson(GoodsItemEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['price'] = entity.price;
  data['picture'] = entity.picture;
  return data;
}

extension GoodsItemEntityExtension on GoodsItemEntity {
  GoodsItemEntity copyWith({
    int? id,
    String? name,
    double? price,
    String? picture,
  }) {
    return GoodsItemEntity()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..price = price ?? this.price
      ..picture = picture ?? this.picture;
  }
}